package com.apestech.framework.run.callback;

import java.util.Vector;

import com.apestech.framework.db.SqlSession;
import com.apestech.framework.db.SqlTemplate;
import com.apestech.framework.util.DBUtil;

public abstract class ReadonlyThreadCallBack implements ThreadCallBackHandler {
	
	private String dbName;
	private Vector<Object> param;
	
	public ReadonlyThreadCallBack(String dbName, Vector<Object> param){
		this.dbName=dbName;
		this.param=param;
	}
	
	@Override
	public void run() throws Exception {
		SqlTemplate cn=null;
		try{
			SqlSession session=DBUtil.getSession();
			this.param.add(session);
			run(session, this.param);
		} catch(Exception e){
			System.out.println(e.getMessage()); 
			throw e;
		}
	}
	
	protected abstract void run(SqlSession cn, Vector<Object> param) throws Exception;
	
}
